<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <link href="../style.css" rel="stylesheet" type="text/css">
    <link rel="icon" href="../images/PETSc_RGB-logo.png" type="image/png" sizes="16x16">
    <title>DMNetwork: Hands on</title>
  </head>
  <body>

    <div id="header">
      <h1>PETSc DMNetwork: Hands on Examples</h1>
    </div>

    <hr>

    <div id="sidebardmnetwork">
      <ul>
        <li><a href="../index.html">PETSc</a></li>
        <li><a href="../documentation/index.html">Documentation</a></li>
        <li>
          <a href="../dmnetwork/index.html">DMNetwork</a>
          <ul>
            <li><a href="case_studies.html">Case Studies</a></li>
            <li><span class="current">Tutorials</a></li>
            <li><a href="publications.html">Publications</a></li>
          </ul>
        </li>
      </ul>
    </div>

    <div id="maindmnetwork">

      <div id="example1">
      <h2 style="color:red;">Example 1: Electric Circuit</h2>
      <p>
        This example demonstrates simulation of a linear problem of electric
        circuit using the DMNetwork interface. Further details:</p>
      <ul>
        <li> <a href="https://gitlab.com/petsc/petsc/-/blob/main/src/ksp/ksp/tutorials/network/ex1.c">petsc/src/ksp/ksp/tutorials/network/ex1.c</a></li>
      </ul>

      </div>
    </div>

    <div id="below">
      <div id="example11">

      <ul>
        <li> Compile ex1.c
          <pre>
            cd petsc/src/ksp/ksp/tutorials/network
            make ex1
          </pre>
        </li>
        <li> Run a 1 processor example and view solution at edges and vertices
          <pre>
            mpiexec -n 1 ./ex1
          </pre>
        </li>
        <li> Run a 1 processor example with a convergence reason
          <pre>
            mpiexec -n 1 ./ex1 -ksp_converged_reason
          </pre>
        </li>
        <li> Run with 2 processors with a partitioning option
          <pre>
            mpiexec -n 2 ./ex1  -petscpartitioner_type simple
          </pre>
        </li>
      </ul>
      </div>

      <div id="example2">
      <h2 style="color:red;">Example 2: AC Power Flow </h2>
      <p>
        This example demonstrates simulation of a nonlinear power flow
        in a grid network using the DMNetwork interface. Further details:</p>
      <ul>
        <li><a href="https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/network/power/power.c">petsc/src/snes/tutorials/network/power/power.c</a></li>
      </ul>


      <ul>
        <li> Compile power.c
          <pre>
            cd petsc/src/snes/tutorials/network/power
            make power
          </pre>
        </li>
        <li> Run a 1 processor example and view solution at vertices
          <pre>
            mpiexec -n 1 ./power
          </pre>
        </li>
        <li> Run with 2 processors with edge and vertex visualization
          <pre>
            mpiexec -n 2 ./power  -dm_view
          </pre>
        </li>
      </ul>
      </div>

      <div id="example3">
      <h2 style="color:red;">Example 3: Water Flow in pipes</h2>
      <p>
        This example demonstrates simulation of a transient water flow
        in a pipe network using the DMNetwork interface. Further details:</p>
      <ul>
        <li><a href="https://gitlab.com/petsc/petsc/-/blob/main/src/ts/tutorials/network/wash/pipes1.c">petsc/src/ts/tutorials/network/wash/pipes1.c</a></li>
      </ul>

      <ul>
        <li> Compile pipes1.c
          <pre>
            cd petsc/src/ts/tutorials/network/wash
            make  pipes1
          </pre>
        </li>
        <li> Run with 2 processors with a partitioning option
          <pre>
            mpiexec -n 2 ./pipes1 -ts_monitor -case 1 -ts_max_steps 1 -petscpartitioner_type
            simple -options_left no -viewX
          </pre>
        </li>
        <li> Run with 3 processors with a different case and more time-stepping options
          <pre>
            mpiexec -n 3 ./pipes1  -ts_monitor -case 2 -ts_max_steps 10 -petscpartitioner_type
            simple -options_left no -viewX
          </pre>
        </li>
      </ul>
      </div>

      <div id="example4">
      <h2 style="color:red;">More Examples</h2>
      <ul>
        <li><a href="https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/network/ex1.c">petsc/src/snes/tutorials/network/ex1.c</a></li>
        <li><a href="https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/network/water/water.c">petsc/src/snes/tutorials/network/water/water.c</a></li>
      </ul>
      </div>
    <hr>
    </div>



  </body>
</html>
